package com.example.springcloud.controller;

import com.example.springcloud.commons.CommonResult;
import com.example.springcloud.entities.Payment;
import com.example.springcloud.service.PaymentFeignService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author weiHuang.zhu
 * @Date 18/4/2023 下午8:24
 */
@RestController
public class OrderController {

    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping("/payment/get/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id) {
        CommonResult<Payment> paymentById = paymentFeignService.getPaymentById(id);

        return paymentById;
    }

    //测试超时
    @GetMapping("/consumer/payment/feign/timeout")
    public String paymentFeignTimeout() {
        //客户端一般默认等待1分钟
        return paymentFeignService.paymentFeignTimeout();
    }

}
